﻿using System;
using static CyberU;
using static CyberU.UI;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;

public class BaseUI : MonoBehaviour
{
    public void Awake()
    {
        
    }

    public Rect rect
    {
        get=>rectTransform.rect;
    }
    public RectTransform _rectTransform;

    public RectTransform rectTransform
    {
        get
        {
            if (_rectTransform == null)
            {
                _rectTransform = GetOrAddComponent<RectTransform>(gameObject);
            }
            return _rectTransform;
        }
        set{_rectTransform = value;}
    }
    public Canvas _canvas;

    public Canvas canvas
    {
        get
        {
            if (_canvas == null)
            {
                _canvas = FindComponentInParent<Canvas>(gameObject);
            }
            return _canvas;
        }
        set{ _canvas = value; }
    }

    void Update()
    {
        OnUpdate();
    }
    public virtual void OnUpdate() { }
}